import re
import wx 
  
#import the newly created GUI file 
import main  
class CalcFrame(main.MyFrame1): 
	def __init__(self,parent): 
		main.MyFrame1.__init__(self,parent)  
		
	'''def FindSquare(self,event): 
		num = int(self.m_textCtrl1.GetValue()) 
		self.m_textCtrl2.SetValue (str(num*num)) '''
		
	def NumberSeven( self, event ):
		value = self.m_textCtrl1.GetValue()
		self.m_textCtrl1.SetValue (value + '7')
	
	def NumberEight( self, event ):
		value = self.m_textCtrl1.GetValue()
		self.m_textCtrl1.SetValue (value + '8')
	
	def NumberNine( self, event ):
		value = self.m_textCtrl1.GetValue()
		self.m_textCtrl1.SetValue (value + '9')
	
	def SymbolAdd( self, event ):
		value = self.m_textCtrl1.GetValue()
		self.m_textCtrl1.SetValue (value + '+')
	
	def NumberFour( self, event ):
		value = self.m_textCtrl1.GetValue()
		self.m_textCtrl1.SetValue (value + '4')
	
	def NumberFive( self, event ):
		value = self.m_textCtrl1.GetValue()
		self.m_textCtrl1.SetValue (value + '5')
	
	def NumberSix( self, event ):
		value = self.m_textCtrl1.GetValue()
		self.m_textCtrl1.SetValue (value + '6')
	
	def SymbolMinus( self, event ):
		value = self.m_textCtrl1.GetValue()
		self.m_textCtrl1.SetValue (value + '-')
	
	def NumberOne( self, event ):
		value = self.m_textCtrl1.GetValue()
		self.m_textCtrl1.SetValue (value + '1')
	
	def NumberTwo( self, event ):
		value = self.m_textCtrl1.GetValue()
		self.m_textCtrl1.SetValue (value + '2')
	
	def NumberThree( self, event ):
		value = self.m_textCtrl1.GetValue()
		self.m_textCtrl1.SetValue (value + '3')
	
	def SymbolMultiply( self, event ):
		value = self.m_textCtrl1.GetValue()
		self.m_textCtrl1.SetValue (value + '*')
	
	def NumberZero( self, event ):
		value = self.m_textCtrl1.GetValue()
		self.m_textCtrl1.SetValue (value + '0')
	
	def SymbolPoint( self, event ):
		value = self.m_textCtrl1.GetValue()
		self.m_textCtrl1.SetValue (value + '.')
	
	def SymbolEqual( self, event ):
		value = self.m_textCtrl1.GetValue()
		#Deal Divided Start
		pattern = re.compile(r'\/(\d+)')
		value = pattern.sub(lambda x:'/float(' + x.group(1) + ')', value)
		#match = pattern.findall(value)
		#Deal Divided END
		value = eval(value)
		self.m_textCtrl1.SetValue (str(value))
	
	def SymbolDivided( self, event ):
		value = self.m_textCtrl1.GetValue()
		self.m_textCtrl1.SetValue (value + '/')
		
app = wx.App(False) 
frame = CalcFrame(None) 
frame.Show(True) 
#start the applications 
app.MainLoop()  